﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ESLab1
{
    public partial class Consult : Form
    {
        public Consult()
        {
            InitializeComponent();
        }

        private void Consult_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("Инженер");
            comboBox1.Items.Add("Ст. инженер");
            comboBox1.Items.Add("Вед. инженер");
            comboBox1.SelectedIndex = 1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Dictionary<string, string> values = new Dictionary<string, string>();

            values.Add("nominal", comboBox1.SelectedItem.ToString());
            values.Add("publication", numericUpDown1.Value.ToString());
            values.Add("author", numericUpDown2.Value.ToString());
            values.Add("experience", numericUpDown3.Value.ToString());

            values.Add("x41", numericUpDown5.Value.ToString());
            values.Add("cf41", numericUpDown4.Value.ToString());

            values.Add("x42", numericUpDown6.Value.ToString());
            values.Add("cf42", numericUpDown7.Value.ToString());

            int x41 = Convert.ToInt32(numericUpDown5.Value);
            int x42 = Convert.ToInt32(numericUpDown6.Value);

            values.Add("hours", Math.Min(x41,x42).ToString());

            RuleExec rules = new RuleExec("rules1.xml");
            rules.ReadBZ(values);
            this.Close();

        }

        private void numericUpDown4_ValueChanged(object sender, EventArgs e)
        {
            if (numericUpDown4.Value + numericUpDown7.Value >= 100)
                numericUpDown7.Value = 100 - numericUpDown4.Value;
        }

        private void numericUpDown7_ValueChanged(object sender, EventArgs e)
        {
            if (numericUpDown7.Value + numericUpDown4.Value >= 100)
                numericUpDown4.Value = 100 - numericUpDown7.Value;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
